package com.sita.tboard.hitchhike;

import android.support.annotation.StringRes;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
import android.view.Gravity;
import android.widget.TextView;

import com.sita.bike.R;
import com.sita.tboard.ActivityBase;

/**
 * Created by xiaodong on 16/4/9.
 */
public abstract class HitchhikeContentActivity extends ActivityBase {

    private Toolbar sToolbar;

    public void customizeToolbar(Toolbar toolbar, String title) {
        initToolbar(toolbar);

        TextView titleView = (TextView)toolbar.findViewById(R.id.toolbar_title);
        titleView.setText(title);
    }

    public void customizeToolbar(Toolbar toolbar, @StringRes int titleResId) {
        initToolbar(toolbar);
        TextView titleView = (TextView)toolbar.findViewById(R.id.toolbar_title);
        titleView.setText(getApplicationContext().getText(titleResId));
    }

    private void initToolbar(Toolbar toolbar){
        sToolbar = toolbar;
        setSupportActionBar(toolbar);
        ActionBar actionBar = getSupportActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowTitleEnabled(false);
        toolbar.setNavigationIcon(R.mipmap.ic_back);
    }

    public void updateToolbarTitle(CharSequence title) {
        if (sToolbar != null){
            TextView titleView = (TextView)sToolbar.findViewById(R.id.toolbar_title);
            titleView.setText(title);
        }
    }
}
